﻿using HttpClientFactoryDemo.Clients;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace HttpClientFactoryDemo.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class OrderController : ControllerBase
    {
        private readonly OrderServiceClient _orderServiceClient;

        public OrderController(OrderServiceClient orderServiceClient)
        {
            _orderServiceClient = orderServiceClient;
        }

        [HttpGet]
        public async Task<string> Get()
        {
            return await _orderServiceClient.Get();
        }

        [HttpGet("NamedGet")]
        public async Task<string> Get([FromServices] NamedOrderServiceClient serviceClient)
        {
            return await serviceClient.Get();
        }

        [HttpGet("TypedGet")]
        public async Task<string> Get([FromServices] TypedOrderServiceClient serviceClient)
        {
            return await serviceClient.Get();
        }
    }
}
